package com.ming.springcloud.student.dao;

import com.ming.springcloud.student.pojo.Book;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Optional;

@Repository("bookDao")
public interface IBookDao extends JpaRepository<Book, Integer> {
    /**
     * 根据id删除
     * @param id
     */
    @Transactional
    void deleteById(Integer id);
    /**
     * 根据id查询所有
     * @param id
     * @return
     */
    @Transactional
    Optional<Book> findById(Integer id);
    /**
     * 根据项目名称模糊查询
     * @param name
     * @return
     */
    @Transactional
    List<Book> findBybookNameLike(String name);


    @Override
    List<Book> findAll();
}
